dofile(getinstalldir().."scripts/kal in ex/journal.lua") 
pouchtype = 3705
bagtype = 3702 
paralyzedspellmessage = "You cannot move."
paralyzedabilitymessage = "The attack has temporarily paralyzed you!"
frozenmessage = "You are frozen and cannot move."

function UseObject(id)
UO.LObjectID = id
UO.Macro(17,0)
end

function FindPouch(ContID)
local cnt = UO.ScanItems(true) 
  for i=0,cnt do
    local id,type,kind,contid,x,y,z,stack,rep,col = UO.GetItem(i)
    if contid == ContID and type == pouchtype then
     return id
    end
  end
return false
end

function FindBag(ContID)
local cnt = UO.ScanItems(true)-1 
  for i=0,cnt do
    local id,type,kind,contid,x,y,z,stack,rep,col = UO.GetItem(i)
    if contid == ContID and type == bagtype then
     return id
    end
  end
return false
end

function MoveItem(id,amount,bag)
  UO.Drag(id,amount)
  wait(100)
  UO.DropC(bag)
  wait(210)
  return true
end

bagid = FindBag(UO.BackpackID)
J = Newjournal() 
while true do
if string.match(J:Get(J:JIndex()) , paralyzedspellmessage ) ~= nil then 
pouchid = FindPouch(UO.BackpackID)
UseObject(pouchid)
MoveItem(pouchid,1,bagid)
wait (9900)  
end
end




